package com.bee.beeAuth.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bee.beeAuth.entity.SysPermission;
import com.bee.beeAuth.service.SysPermissionService;
import com.bee.beeModel.result.Result;
import com.bee.beeModel.result.ResultTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/beeAuth/sys-permission")
@Api(value ="权限表",tags = "权限表")
public class SysPermissionController {

    @Resource
    private SysPermissionService sysPermissionService;

    /**
    * 权限表分页查询
    * @param page
    * @param sysPermission
    * @return
    */
    @ApiOperation(value = "权限表分页查询", notes = "权限表分页查询")
    @GetMapping("/page")
    public Result getGenFormConfPage(Page page, SysPermission sysPermission) {
        return ResultTool.success(sysPermissionService.page(page, Wrappers.query(sysPermission)));
    }

    /**
    * 根据id查询权限表
    * @param id
    * @return
    */
    @ApiOperation(value = "通过id查询权限表", notes = "通过id查询权限表")
    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") String id) {
        return ResultTool.success(sysPermissionService.getById(id));
    }
}